<?php


namespace App\Http\Controllers\admin\api;


use App\Http\Controllers\admin\service\BannerService;
use App\Http\Controllers\admin\validate\Banner;
use App\Http\Controllers\utils\ToolUtil;
use Illuminate\Http\Request;

class BannerApi
{
    public function addBanner(Request $request){
        $param = $request->all();
        $data = Banner::addBanner($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return BannerService::addBanner($param);
    }

    public function queryBanner(Request $request){
        $param = $request->all();
        $data = Banner::queryBanner($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return BannerService::queryBanner($param);
    }

    public function queryIdBanner(Request $request){
        $param = $request->all();
        $data = Banner::queryIdBanner($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return BannerService::queryIdBanner($param);
    }

    public function editBanner(Request $request){
        $param = $request->all();
        $data = Banner::editBanner($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return BannerService::editBanner($param);
    }

    public function deleteBanner(Request $request){
        $param = $request->all();
        $data = Banner::deleteBanner($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return BannerService::deleteBanner($param);
    }
}